package org.example.entity;

import lombok.Data;

/**
 * @author TonySong
 * @date 2024/6/27 0027
 * @time 11:26
 */
@Data
public class R<T> {
    private Integer code;
    private String msg;
    private Boolean flag;
    private T data;

    public static <T> R<T> success(T data) {
        R<T> r = new R<>();
        r.setCode(200);
        r.setMsg("success");
        r.setFlag(true);
        r.setData(data);
        return r;
    }

    public static <T> R<T> error(Integer code, String msg) {
        R<T> r = new R<>();
        r.setCode(code);
        r.setMsg(msg);
        r.setFlag(false);
        return r;
    }
}
